# -*- coding: utf8 -*- #
# ! /usr/python3


import sys
import decimal


_DIGIT_HZ = [u'零', u'壹', u'贰',
             u'叁', u'肆', u'伍', u'陆', u'柒', u'捌', u'玖']
_HZ_YI = u'亿'
_HZ_WAN = u'万'
_HZ_QIAN = u'仟'
_HZ_BAI = u'佰'
_HZ_SHI = u'拾'
_HZ_YUAN = u'元'
_HZ_ZHENG = u'整'
_HZ_JIAO = u'角'
_HZ_FEN = u'分'

_HZ_UNIT = [
    _HZ_YUAN, _HZ_SHI, _HZ_BAI, _HZ_QIAN, _HZ_WAN,
    _HZ_SHI, _HZ_BAI, _HZ_QIAN, _HZ_YI,
    _HZ_SHI, _HZ_BAI, _HZ_QIAN, _HZ_WAN,
    _HZ_SHI, _HZ_BAI, _HZ_QIAN]


def do_cvt(d: decimal.Decimal) -> str:
    if d is None:
        return ''

    if d.is_zero():
        return _DIGIT_HZ[0] + _HZ_UNIT[0]

    buf = []
    sb = ''

    d0 = d.copy_abs()
    l = int(d0)  # 整数部分。
    p = d0 - l  # 小数部分。
    if l != 0:
        while l >= 10:
            buf.append(l % 10)
            l = l // 10
        buf.append(l)

        prev_zero = False
        i = len(buf) - 1
        while i >= 0:
            dd = buf[i]
            if dd == 0:
                if i % 4 == 0:
                    sb = sb + _HZ_UNIT[i]

                prev_zero = True
            else:
                if prev_zero:
                    sb = sb + _DIGIT_HZ[0]
                sb = sb + _DIGIT_HZ[dd] + _HZ_UNIT[i]

                prev_zero = False

            i = i - 1

    if not p.is_zero():
        mi = int(p.scaleb(2))
        jiao = mi // 10
        fen = mi % 10
        if jiao != 0:
            sb = sb + _DIGIT_HZ[jiao] + _HZ_JIAO
        if fen != 0:
            sb = sb + _DIGIT_HZ[fen] + _HZ_FEN
    else:
        sb = sb + _HZ_ZHENG

    return sb if not d.is_signed() else '负' + sb


if __name__ == '__main__':
    if len(sys.argv) <= 1:
        sys.exit(1)

    a0 = sys.argv[1].strip()

    d: decimal.Decimal = None
    try:
        d = decimal.Decimal(a0)
    except decimal.InvalidOperation:
        print('Illegal decimal:', a0, file=sys.stderr)
        sys.exit(2)

    if d.is_finite():
        print(do_cvt(decimal.Decimal(a0)))
    else:
        print('Infinate decimal:', d, file=sys.stderr)
        sys.exit(3)
